#include "cxxcall.hpp"
#include <stdexcept>
#include <cstdio>

#if defined (CXXCALL_AMD64)
  #include "sysdeps/x86-64/callin-arg.cpp"
#elif defined (CXXCALL_I386)
  #include "sysdeps/i386/callin-arg.cpp"
#elif defined (CXXCALL_ARM64)
  #include "sysdeps/aarch64/callin-arg.cpp"
#elif defined (CXXCALL_ARM32)
  #include "sysdeps/arm/callin-arg.cpp"
#else
#  error "unsupported platform"
#endif

namespace cxxcall
{

void cb_data::_Assert_rtype (int type)
{
  if (type != this->rtype)
    {
      char buf[100];
      sprintf (buf, "Invalid return type (got %d, expected %d)",
        type, (int)this->rtype);
      throw std::runtime_error (buf);
    }
}

} // namespace cxxcall
